<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>属性动态绑定</title>
  <style>
    .active {
      width: 200px;
      height: 100px;
      border: 1px solid red;
    }

    .font {
      color: yellow;
    }

    .bgc {
      background-color: violet;
    }
  </style>
</head>

<body>

  <div class="app">
    <!-- <p :class='{active:isActive,font:isActive}'>对象方法绑定</p>
    <p :class='objStyle'>对象方法简写</p>


    <p v-bind:class='[actClass,fontClass]'>数组方法绑定</p>
    <p v-bind:class='arrclass'>数组方法绑定简写</p> -->


    <!-- 数组和对象绑定的三个细节 -->
    <!-- 1.可以同时使用 -->
    <p v-bind:class='[actClass,fontClass,{bgc:isActive}]'>同时使用</p>

    <!-- 2.数组和对象方法都可以简写 -->
    <p :class='objStyle'>对象方法简写</p>
    <p v-bind:class='arrclass'>数组方法绑定简写</p>

    <!-- 3.动态绑定类名时，默认类名会如何处理 -->
    <!-- 两个类名都会生效 -->
    <p class="font" :class='{active:isActive,bgc:isActive}'>会同时生效</p>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    var vm = new Vue({
      el: '.app',
      data: {
        isActive: true,
        objStyle: {
          active: true,
          font: true
        },
        actClass: 'active',
        fontClass: 'font',
        arrclass: ['active', 'font']
      }
    })
  </script>
</body>

</html>